#ifndef SWF_H
#define SWF_H

#include <cstdio>
#include <vector>

#include "type.h"

//#define FontID CharacterID
//#define shape_id CharacterID

static const uint16 TAG_TYPE_END=0;
static const uint16 TAG_TYPE_SHOW_FRAME=1;
static const uint16 TAG_TYPE_DEFINE_SHAPE=2;
static const uint16 TAG_TYPE_SET_BACKGROUND_COLOR=9;
static const uint16 TAG_TYPE_DEFINE_BITS_LOSSLESS=20;
static const uint16 TAG_TYPE_PLACE_OBJECT2=26;
static const uint16 TAG_TYPE_DEFINE_SHAPE3=32;
static const uint16 TAG_TYPE_DEFINE_TEXT2=33;
static const uint16 TAG_TYPE_DEFINE_FONT2=48;
static const uint16 TAG_TYPE_FILE_ATTRIBUTES=69;
static const uint16 TAG_TYPE_CSM_TEXT_SETTINGS=74;



#include "RGB.h"
namespace swfstream{
	class COLORMAPDATA{
		public:
			std::vector<RGB*>* ColorTableRGB;///< RGB[color table size] Defines the mapping from color indices to RGB values. Number of RGB values is BitmapColorTableSize + 1.
			uint8* ColormapPixelData;///< UI8[image data size] Array of color indices. Number of entries is BitmapWidth * BitmapHeight, subject to padding (see note preceding this table).
			//std::vector<uint8>* ColormapPixelData;///< UI8[image data size] Array of color indices. Number of entries is BitmapWidth * BitmapHeight, subject to padding (see note preceding this table).
			static COLORMAPDATA* from_file(FILE* f,uint color_table_size,uint image_data_size);
			static COLORMAPDATA* from_mem(byte* mem,uint mem_size,uint color_table_size,uint width,uint height);
			void print();
	};
}
#include "ShapeRecord.h"
namespace swfstream{
	class STRAIGHTEDGERECORD:public ShapeRecord{
		public:
			STRAIGHTEDGERECORD(){
				DeltaX=DeltaY=0;
			}
			void print();
			uint NumBits;///< UB[4] Number of bits per value(2 less than the actual number).
			bool GeneralLineFlag;///< UB[1] General Line equals 1.Vert/Horz Line equals 0.
			bool VertLineFlag;///< If GeneralLineFlag = 0, SB[1] Vertical Line equals 1.Horizontal Line equals 0.
			int DeltaX;///< If GeneralLineFlag = 1 or if VertLineFlag = 0, SB[NumBits+2] X delta.
			int DeltaY;///< If GeneralLineFlag = 1 or if VertLineFlag = 1, SB[NumBits+2] Y delta.
	};

	class CURVEDEDGERECORD:public ShapeRecord{
		public:
			uint NumBits;///< UB[4] Number of bits per value(2 less than the actual number).
			int ControlDeltaX;///< SB[NumBits+2] X control point change.
			int ControlDeltaY;///< SB[NumBits+2] Y control point change.
			int AnchorDeltaX;///< SB[NumBits+2] X anchor point change.
			int AnchorDeltaY;///< SB[NumBits+2] Y anchor point change.
	};
}
#include<map>
#include "Defination.h"

namespace swfstream{
	class Dictionary:public std::map<uint,Defination*>{};
}
#endif
